package com.javaxiaobear.module.system.domain;

import com.javaxiaobear.base.framework.web.domain.BaseEntity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.RelationOneToMany;
import com.mybatisflex.annotation.Table;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 部门表 sys_dept
 *
 * @author javaxiaobear
 */
@EqualsAndHashCode(callSuper = true)
@Table(value = "sys_dept")
@Data
public class SysDept extends BaseEntity {

  /** 部门ID */
  @Id private Long deptId;

  /** 父部门ID */
  @Column(value = "parent_id")
  private Long parentId;

  /** 祖级列表 */
  @Column(value = "ancestors")
  private String ancestors;

  /** 部门名称 */
  @Column(value = "dept_name")
  @NotBlank(message = "部门名称不能为空")
  @Size(max = 30, message = "部门名称长度不能超过30个字符")
  private String deptName;

  /** 显示顺序 */
  @Column(value = "order_num")
  @NotNull(message = "显示顺序不能为空")
  private Integer orderNum;

  /** 负责人 */
  @Column(value = "leader")
  private String leader;

  /** 联系电话 */
  @Column(value = "phone")
  @Size(max = 11, message = "联系电话长度不能超过11个字符")
  private String phone;

  /** 邮箱 */
  @Column(value = "email")
  @Email(message = "邮箱格式不正确")
  @Size(max = 50, message = "邮箱长度不能超过50个字符")
  private String email;

  /** 部门状态:0正常,1停用 */
  @Column(value = "status")
  private String status;

  /** 删除标志（0代表存在 2代表删除） */
  @Column(value = "del_flag")
  private String delFlag;

  /** 父部门名称 */
  @Column(ignore = true)
  private String parentName;

  /** 子部门 */
  @Column(ignore = true)
  @RelationOneToMany(selfField = "deptId", targetField = "parentId")
  private List<SysDept> children = new ArrayList<>();
}
